<template>
    <rx-layout>
      <template v-slot:center>
        <rx-grid ref="rxGrid" :queryParam="queryParam" :url="'/api-bpm/bpm/core/bpmAsyncTask/query'">
          <template v-slot:center="{record}">
              <view class="rx-center" @click="bpmDetails(record,'detail')">
                  <view class="rx-createTime">
                      <my-icon style="color: rgba(66, 133, 244, 1);font-size: 1.2rem"
                               type="icon-linetime"></my-icon>
                      <view class="rx-createTime-name">{{record.createTime}}</view>
                  </view>
                  <view class="rx-top">
                      <view class="rx-icon-le"><view class="rx-icon_liucheng"><my-icon type="icon-Vue3jpaas-icon_liucheng"></my-icon></view></view>
                      <view class="rx-subject">{{ record.taskName }}</view>
                  </view>
                  <view class="rx-bottom">
                      <view class="rx-bottom-list">
                          <span class="rx-bottom-span">{{ i18n('nodeName', '节点名称') }}:</span>
                          <span class="rx-bottom-name">{{ record.nodeName }}</span>
                      </view>
                  </view>
                  <view class="rx-operate">
                      <view class="rx-operate-button" @click.stop="delByIds(record)">
                          <my-icon type="icon-Vue3_delete"></my-icon>
                          {{ i18n('delBtn', '删除') }}
                      </view>
                  </view>
              </view>
          </template>
        </rx-grid>
      </template>
    </rx-layout>
</template>

<script>
import RxGrid from '@/components/RxGrid'
import RxLayout from '@/components/RxLayout'
import getStatusHtml from '@/common/getStatusHtml.js'
import GatewayApi from "@/api/Gateway/GatewayApi";
export default {
  name: "RxMyAsynchronous", components: {RxGrid, RxLayout},
  mixins:[getStatusHtml],
  data() {
    return {
      queryParam: {
        Q_CREATE_BY__S_EQ: ""
      },//筛选参数
    }
  },
    created(){
        this.queryParam.Q_CREATE_BY__S_EQ = uni.getStorageSync("user").userId;
    },
  methods: {
    i18n(name, text, key) {
      return this.$ti18(name, text, "bpmLang", key);
    },
    //删除我的异步
    delByIds(record){
        let self = this;
        uni.showModal({
            title: this.$ti18('rxMsa.tipsInfo','提示信息'),
            content: this.i18n('sureDelete','确定删除？'),
            confirmText: self.$ti18('rxForm.okBtn', '确定'),
            cancelText: self.$ti18('rxForm.cancelBtn', '取消'),
            success: function (res) {
                if (res.confirm) {
                    GatewayApi.bpmAsyncTaskDel(record.id).then(res => {
                        if (res.success) {
                            uni.showToast({
                                title: res.message, // 消息内容
                                duration: 2000, // 持续时间（单位：毫秒）
                                icon: 'none' // 图标类型（可选值：success/loading/none）
                            });
                            self.$refs.rxGrid.getInit(true,true)
                        }else {
                            uni.showToast({
                                title: res.message, // 消息内容
                                duration: 2000, // 持续时间（单位：毫秒）
                                icon: 'none' // 图标类型（可选值：success/loading/none）
                            });
                        }
                    })
                } else if (res.cancel) {
                    console.log('用户点击取消');
                }
            }
        });
    },
      bpmDetails(obj){
          uni.navigateTo({
              url:'/pages/RxProcessManagement/RxMyAsynchronous/RxAsynchronousDetails?pkId='+obj.pkId+'&appId='+obj.appId
          })
      },
  }
}
</script>

<style scoped>
@import "../RxProcessManagement.css";
</style>
